package com.liveinstars.gateway.business.entity;

import com.alibaba.fastjson.JSON;
import com.liveinstars.gateway.business.repository.po.AuthSecret;

/**
 * @author: ting
 * @date: 2019-08-13
 */
public class AuthSecretDTO extends AuthSecret {

    private SecretKeyDTO secretKeyDTO;

    public SecretKeyDTO getSecretKeyDTO() {
        return secretKeyDTO;
    }

    public void setSecretKeyDTO(SecretKeyDTO secretKeyDTO) {
        this.secretKeyDTO = secretKeyDTO;
    }

    @Override
    public String toString() {
        return "AuthSecretDTO{" +
                "secretKeyDTO=" + secretKeyDTO +
                '}';
    }

    public void copyFromAuthSecret(AuthSecret source) {
        this.setId(source.getId());
        this.setSecretKey(source.getSecretKey());
        this.setAppId(source.getAppId());
        this.setState(source.getState());
        this.setStatus(source.getStatus());
        this.setType(source.getType());
        this.setVersion(source.getVersion());
        this.setSecretKeyDTO(JSON.parseObject(source.getSecretKey(), SecretKeyDTO.class));
    }
}
